import Vue from 'vue'
import VueResource from 'vue-resource'
Vue.use(VueResource)

Vue.http.options.root = '/'
Vue.http.options.crossOrigin = true
// 为每个POST的请求添加_token
Vue.http.interceptors.push((request, next) => {
  // modify request
  if (request.method !== 'GET') {
    if (!request.body) {
      request.body = {}
    }
    request.body['_token'] = window._token
  }
  // continue to next interceptor
  next()
})
const resource = Vue.resource

export default resource
